home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 302_01.zip / DELF.C < prev    next >
Text File  |  1993-04-09  |  2KB  |  55 lines

  1. /* Delete face from object
  2.  
  3.    Copyright (c) 1988 by Gus O'Donnell
  4.  
  5.    Revision history:
  6.  
  7.    Version 1.00         February 29, 1988       As released.
  8.  
  9.    Version 1.01         March 20, 1988          Created libraries for all
  10.                                                 memory models
  11.  
  12. */
  13. #include <3d.h>
  14. #include <alloc.h>
  15. #include <float.h>
  16. #include <math.h>
  17. #include <stdio.h>
  18.  
  19. int     del_face (OBJECT *this_obj, FACE *this_face)
  20.  
  21. /* Delete a face from an object.  The list of faces is traversed
  22. until the face is located, then it is unlinked from the list.
  23. The function returns a 0 if the operation completes successfully.
  24. The function returns a 1 if the face isn't found. */
  25.  
  26. {
  27.     FACE *fhandle;      /* Pointer to traverse the face list */
  28.     CORNER *chandle;    /* Temporary pointer to free corners */
  29.     int not_done;
  30.  
  31.     fhandle = this_obj -> faces;
  32.     not_done = 1;
  33.     while ((fhandle -> next -> next != NULL) && not_done)
  34.     {
  35.         if (fhandle -> next == this_face)
  36.         {
  37.  
  38.             /* Unlink the face */
  39.  
  40.             fhandle -> next = fhandle -> next -> next;
  41.  
  42.             /* Free the corners */
  43.  
  44.             do {
  45.                 chandle = this_face -> first;
  46.                 this_face -> first = this_face -> first -> next;
  47.                 free (chandle);
  48.             } while (this_face -> first != NULL);
  49.             free (this_face);
  50.             not_done = 0;
  51.         }
  52.         fhandle = fhandle -> next;
  53.     }
  54.     return (not_done);
  55. }